﻿/*
* ============================================================================
* GNU Lesser General Public License
* ============================================================================
*
* BYDAN - Free Java BYDAN library.
* Copyright (C) 2008 
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
* 
* BYDAN Corporation
*/
package ByDan.AulaVirtual.Business.Entities;

import java.util.ArrayList;
import ByDan.Framework.AulaVirtual.Business.Entities.GeneralEntity;
import ByDan.Framework.AulaVirtual.Business.Entities.Mensajes;
import ByDan.Framework.AulaVirtual.Utils.ParameterDbType;
import ByDan.Framework.AulaVirtual.Utils.ParameterType;
import ByDan.Framework.AulaVirtual.Utils.ParametersMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterValue;
import ByDan.Framework.AulaVirtual.Utils.ParametersType;
import java.sql.*;

public class Alumno extends GeneralEntity
{
	static  String strTableName="Alumno";
		
	public static String getStrTableName() 
	{
		return strTableName;
	}

	public static void setStrTableName(String strTableName) 
	{
		Alumno.strTableName = strTableName;
	}
	
	public static String getColumnNameId()
	{
		return "id";
	}
	
	public Alumno alumnoOriginal;
	
	public Alumno getAlumnoOriginal()
	{
		return alumnoOriginal;
	}
	
	public  void  setAlumnoOriginal(Alumno alumno)
	{
		try
		{
			alumnoOriginal=alumno;
		}
		catch(Exception ex)
		{
			;
		}
	}
	
	
	
	
	 
	
	
	
	
	
	ArrayList<UnidadCurricularTutorAlumno> relationship_unidadcurriculartutoralumnos;
	ArrayList<Tutoria> relationship_tutorias;
	ArrayList<Respuesta> relationship_respuestas;
	ArrayList<TutoriaAlumno> relationship_tutoriaalumnos;
	ArrayList<AlumnoRespuesta> relationship_alumnorespuestas;
	ArrayList<UnidadCurricularTutor> relationship_unidadcurriculartutors;
	
	
	public ArrayList<UnidadCurricularTutorAlumno> getRelationship_unidadcurriculartutoralumnos()
	{
		return relationship_unidadcurriculartutoralumnos;
	}

	public ArrayList<Tutoria> getRelationship_tutorias()
	{
		return relationship_tutorias;
	}

	public ArrayList<Respuesta> getRelationship_respuestas()
	{
		return relationship_respuestas;
	}

	public ArrayList<TutoriaAlumno> getRelationship_tutoriaalumnos()
	{
		return relationship_tutoriaalumnos;
	}

	public ArrayList<AlumnoRespuesta> getRelationship_alumnorespuestas()
	{
		return relationship_alumnorespuestas;
	}

	public ArrayList<UnidadCurricularTutor> getRelationship_unidadcurriculartutors()
	{
		return relationship_unidadcurriculartutors;
	}

	
	
	public  void  setRelationship_UnidadCurricularTutorAlumno(ArrayList<UnidadCurricularTutorAlumno> unidadcurriculartutoralumnos)
	{
		try
		{
			this.relationship_unidadcurriculartutoralumnos=unidadcurriculartutoralumnos;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_Tutoria(ArrayList<Tutoria> tutorias)
	{
		try
		{
			this.relationship_tutorias=tutorias;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_Respuesta(ArrayList<Respuesta> respuestas)
	{
		try
		{
			this.relationship_respuestas=respuestas;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_TutoriaAlumno(ArrayList<TutoriaAlumno> tutoriaalumnos)
	{
		try
		{
			this.relationship_tutoriaalumnos=tutoriaalumnos;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_AlumnoRespuesta(ArrayList<AlumnoRespuesta> alumnorespuestas)
	{
		try
		{
			this.relationship_alumnorespuestas=alumnorespuestas;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_UnidadCurricularTutor(ArrayList<UnidadCurricularTutor> unidadcurriculartutors)
	{
		try
		{
			this.relationship_unidadcurriculartutors=unidadcurriculartutors;
		}
		catch(Exception ex)
		{
			;
		}
	}

	
	private static Boolean blnDeleteCascade=false;
	private static String QueryInsert="insert into aulavirtualme_dbo.Alumno set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,CEDULA=?,NOMBRES=?,APELLIDOS=?";
	private static String QueryUpdate="update aulavirtualme_dbo.Alumno set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,CEDULA=?,NOMBRES=?,APELLIDOS=? where id=? AND versionRow=?";
	private static String QueryDelete="delete from aulavirtualme_dbo.Alumno where id=?";
	public static String QuerySelect="select aulavirtualme_dbo.Alumno.id,aulavirtualme_dbo.Alumno.isActive,aulavirtualme_dbo.Alumno.isExpired,aulavirtualme_dbo.Alumno.versionRow,aulavirtualme_dbo.Alumno.CEDULA,aulavirtualme_dbo.Alumno.NOMBRES,aulavirtualme_dbo.Alumno.APELLIDOS from aulavirtualme_dbo.Alumno";
	 
	String field_strCedula;
	String field_strNombres;
	String field_strApellidos;
				
	public Alumno ()
    {
		super();		
 		field_strCedula="";
 		field_strNombres="";
 		field_strApellidos="";
		
		
		
		
		relationship_unidadcurriculartutoralumnos=new ArrayList<UnidadCurricularTutorAlumno>();
		relationship_tutorias=new ArrayList<Tutoria>();
		relationship_respuestas=new ArrayList<Respuesta>();
		relationship_tutoriaalumnos=new ArrayList<TutoriaAlumno>();
		relationship_alumnorespuestas=new ArrayList<AlumnoRespuesta>();
		relationship_unidadcurriculartutors=new ArrayList<UnidadCurricularTutor>();
		
		super.setQueryInsert(QueryInsert);
		super.setQueryUpdate(QueryUpdate);
		super.setQueryDelete(QueryDelete);
		super.setQuerySelect(QuerySelect);
		
    } 
	
	public static Boolean getBlnDeleteCascade() 
	{
		return blnDeleteCascade;
	}

	public static void setBlnDeleteCascade(Boolean blnDeleteCascade) 
	{
		Alumno.blnDeleteCascade = blnDeleteCascade;
	}
	
	public static String getTableName()
    {
         return "aulavirtualme_dbo.Alumno";
    }
	
    
	public static String getColumnNameCedula()
	{
		return "Cedula";
	}
    
	public static String getColumnNameNombres()
	{
		return "Nombres";
	}
    
	public static String getColumnNameApellidos()
	{
		return "Apellidos";
	}
     
    
	public String getField_strCedula()
	{
		return field_strCedula;
	}
    
	public String getField_strNombres()
	{
		return field_strNombres;
	}
    
	public String getField_strApellidos()
	{
		return field_strApellidos;
	}
	
    
	public void setField_strCedula(String newField_strCedula)throws Exception
	{
		try
		{
			if(this.field_strCedula!=newField_strCedula)
			{
				if(newField_strCedula==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Alumno.getColumnNameCedula());
				}

				this.field_strCedula=newField_strCedula;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strNombres(String newField_strNombres)throws Exception
	{
		try
		{
			if(this.field_strNombres!=newField_strNombres)
			{
				if(newField_strNombres==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Alumno.getColumnNameNombres());
				}

				this.field_strNombres=newField_strNombres;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strApellidos(String newField_strApellidos)throws Exception
	{
		try
		{
			if(this.field_strApellidos!=newField_strApellidos)
			{
				if(newField_strApellidos==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Alumno.getColumnNameApellidos());
				}

				this.field_strApellidos=newField_strApellidos;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
		
	public  void BuildParametersMaintenance(ParameterDbType newDbType,ParametersType parametersType) throws Exception
	{
		try
		{
			ParametersMaintenance parametersMaintenance=super.getParametersMaintenance();		
			ArrayList<ParameterMaintenance> parametersTemp=new ArrayList<ParameterMaintenance>();
			ParameterMaintenance parameterMaintenance;
			ParameterValue<Long> parameterMaintenanceValueId;
			
				if(!parametersType.equals(ParametersType.DELETE))
				{		
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsactive=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsactive.setValue(this.getIsActive());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsactive);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(2);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsexpired=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsexpired.setValue(this.getIsExpired());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsexpired);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(3);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueCedula=new ParameterValue<String>();
					parameterMaintenanceValueCedula.setValue(this.getField_strCedula());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueCedula);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(4);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueNombres=new ParameterValue<String>();
					parameterMaintenanceValueNombres.setValue(this.getField_strNombres());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueNombres);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(5);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueApellidos=new ParameterValue<String>();
					parameterMaintenanceValueApellidos.setValue(this.getField_strApellidos());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueApellidos);
					parametersTemp.add(parameterMaintenance);
					
						if(parametersType.equals(ParametersType.UPDATE))
						{					
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(6);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
							parameterMaintenanceValueId=new ParameterValue<Long>();
							parameterMaintenanceValueId.setValue(this.getId());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
							parametersTemp.add(parameterMaintenance);
							
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(7);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.TIMESTAMP);
							ParameterValue<Timestamp> parameterMaintenanceValueVersionRow=new ParameterValue<Timestamp>();
							parameterMaintenanceValueVersionRow.setValue(this.getVersionRow());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueVersionRow);		
							parametersTemp.add(parameterMaintenance);					
						}
				}
				else
				{
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					parameterMaintenanceValueId=new ParameterValue<Long>();
					parameterMaintenanceValueId.setValue(this.getId());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
					parametersTemp.add(parameterMaintenance);
				}
			
			parametersMaintenance= new ParametersMaintenance();
			parametersMaintenance.setDbType(newDbType);
			parametersMaintenance.setParametersMaintenance(parametersTemp);
			super.setParametersMaintenance(parametersMaintenance);		
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
}
